use repeated_cross_section, clear

// muslim indicator
gen muslim=(paiperc=="06"|paiperc=="08")

// muslim mother
gen mothermuslim=(paimerc=="06"|paimerc=="08")
gen bothparents=(muslim==1&mothermuslim==1)
gen fatheronly=(muslim==1&mothermuslim==0)

// interactions
gen inter=muslim*treatedcoh
foreach x in bothparents fatheronly {
	gen inter`x'=`x'*treatedcoh
}

// linear trend
tab birthyear, gen(coh)
sum birthyear
local minyear=r(min)
local maxyear=r(max)-r(min)
gen t=birthyear-`minyear'+1
gen tmuslim=t*muslim

// father-mother birthplace FE
egen pbpl=group(paiperc)
egen mbpl=group(paimerc)

estimates clear
local sample if pnai28=="10" & female==1
local cl pbpl
estimates clear
reghdfe secondary inter `sample', cluster(`cl') absorb(i.pbpl i.birthyear)
eststo m1

reghdfe secondary inter `sample', cluster(`cl') absorb(i.pbpl i.birthyear i.surveyr)
eststo m2

reghdfe secondary inter `sample', cluster(`cl') absorb(i.pbpl i.birthyear i.ag##i.pbpl i.surveyr)
eststo m3

reghdfe secondary inter tmuslim `sample', cluster(`cl') absorb(i.pbpl i.birthyear i.ag##i.pbpl i.surveyr)
eststo m4

reghdfe secondary interfatheronly interbothparents  bothparents `sample', cluster(`cl') absorb(i.pbpl i.mbpl i.birthyear i.ag##i.pbpl i.surveyr)
eststo m5


esttab m* using "Table1.csv", star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace ///
		cells(b(fmt(a3) star) se(par)) stats(N r2)  ///
		keep(inter*) 
